#!/bin/sh
#
# This is the script for generating files for a specific Dalton test job.
#
# For the .check file ksh or bash is preferred, otherwise use sh
# (and hope it is not the old Bourne shell, which will not work)
#
if [ -x /bin/ksh ]; then
   CHECK_SHELL='#!/bin/ksh'
elif [ -x /bin/bash ]; then
   CHECK_SHELL='#!/bin/bash'
else
   CHECK_SHELL='#!/bin/sh'
fi


#######################################################################
#  TEST DESCRIPTION
#######################################################################
cat > cc2_r12_aux_ch4_a2_tight.info <<'%EOF%'
   cc2_r12_aux_ch4_a2_tight
   -------------
   Molecule:         Methane (CH4)
   Wave Function:    CC2-R12 / 6-311G**
   Test Purpose:     Check CC2-R12 method for ansatz2 with auxiliary 
                     basis but without symmetry
%EOF%

#######################################################################
#  MOLECULE INPUT
#######################################################################
cat > cc2_r12_aux_ch4_a2_tight.mol <<'%EOF%'
INTGRL
CC2-R12/B calculation without symmetry                                          
                                                                                
    4  0 0            0.10D-14
 1      6.    1    3    3    2    1
C        1.0900000000000    -0.1200000000000     7.2890100000000
H   6    1
     4563.2400000000        0.0019666500    
      682.0240000000        0.0152306000    
      154.9730000000        0.0761269000    
       44.4553000000        0.2608010000    
       13.0290000000        0.6164620000    
        1.8277300000        0.2210060000    
H   3    1
       20.9642000000        0.1146600000     
        4.8033100000        0.9199990000     
        1.4593300000       -0.0030306800     
F   2    0
        0.4834560000   
        0.1455850000   
H   3    1
       20.9642000000        0.0402487000    
        4.8033100000        0.2375940000    
        1.4593300000        0.8158540000    
F   2    0
        0.4834560000   
        0.1455850000   
F   1    0
        0.6260000000       
 1      1.    4    2    2    1
H        2.8715308320486     0.1736528344531     8.5657410000000
H       -0.6915308320486    -0.4136528344531     8.5657410000000
H        0.7963471655469     1.6615308320486     6.0122790000000
H        1.3836528344531    -1.9015308320486     6.0122790000000
H   3    1
       33.8650000000        0.0254938000   
        5.0947900000        0.1903730000   
        1.1587900000        0.8521610000   
F   2    0
        0.3258400000   
        0.1027410000   
F   1    0
        0.7500000000        
 2      6.    1    3    3    2    1
C        1.0900000000000    -0.1200000000000     7.2890100000000
H   6    1
     4563.2400000000        0.0019666500    
      682.0240000000        0.0152306000    
      154.9730000000        0.0761269000    
       44.4553000000        0.2608010000    
       13.0290000000        0.6164620000    
        1.8277300000        0.2210060000    
H   3    1
       20.9642000000        0.1146600000     
        4.8033100000        0.9199990000     
        1.4593300000       -0.0030306800     
F   2    0
        0.4834560000   
        0.1455850000   
H   3    1
       20.9642000000        0.0402487000    
        4.8033100000        0.2375940000    
        1.4593300000        0.8158540000    
F   2    0
        0.4834560000   
        0.1455850000   
F   1    0
        0.6260000000       
 2      1.    4    2    2    1
H        2.8715308320486     0.1736528344531     8.5657410000000
H       -0.6915308320486    -0.4136528344531     8.5657410000000
H        0.7963471655469     1.6615308320486     6.0122790000000
H        1.3836528344531    -1.9015308320486     6.0122790000000
H   3    1
       33.8650000000        0.0254938000   
        5.0947900000        0.1903730000   
        1.1587900000        0.8521610000   
F   2    0
        0.3258400000   
        0.1027410000   
F   1    0
        0.7500000000        
%EOF%

#######################################################################
#  DALTON INPUT
#######################################################################
cat > cc2_r12_aux_ch4_a2_tight.dal <<'%EOF%'
**DALTON INPUT
.RUN WAVE FUNCTION
.DIRECT
*MOLBAS
.R12AUX
**INTEGRALS
.R12
**WAVE FUNCTION
.CC
*ORBITAL INPUT
.MOSTART
 H1DIAG
*SCF INPUT
.THRESH
 1.0D-10
*CC INPUT
.CC2
.PRINT
 3  
.FROIMP
  1 
  0 
.THRENR
 1.0D-10
.MAX IT
 120
.MAXRED
 900
*CCEXCI
.THREXC
 1.D-8
.NCCEXCI
 8 
*R12 INPUT
.NO HYB
.CC2
 2B
**END OF DALTON INPUT
%EOF%

#######################################################################

 

#######################################################################

#######################################################################
#  CHECK SCRIPT
#######################################################################
echo $CHECK_SHELL >cc2_r12_aux_ch4_a2_tight.check
cat >>cc2_r12_aux_ch4_a2_tight.check <<'%EOF%'
log=$1

if [ `uname` = Linux ]; then
   GREP="egrep -a"
else
   GREP="egrep"
fi

if $GREP -q "not implemented for parallel calculations" $log; then
   echo "TEST ENDED AS EXPECTED"
   exit 0
fi


#             Total SCF   energy:                   -40.1917720926
#             Total MP2-R12/B energy:               -40.3940351575
#             Total CC2-R12/B energy:               -40.3953862545
# 
# 
#  +=============================================================================+
#  |  sym. | Exci.  |        CC2-R12/B  Excitation energies            | ||T1||  |
#  |(spin, |        +------------------------------------------------------------+
#  | spat) |        |     Hartree    |       eV.      |     cm-1       |    %    |
#  +=============================================================================+
#  | ^1A   |    1   |     0.4176046  |      11.36360  |     91653.620  |  97.02  |
#  | ^1A   |    2   |     0.4176046  |      11.36360  |     91653.620  |  97.05  |
#  | ^1A   |    3   |     0.4176046  |      11.36360  |     91653.620  |  97.05  |
#  | ^1A   |    4   |     0.4827791  |      13.13709  |    105957.755  |  97.04  |
#  | ^1A   |    5   |     0.4827791  |      13.13709  |    105957.755  |  97.02  |
#  | ^1A   |    6   |     0.4827791  |      13.13709  |    105957.755  |  97.01  |
#  | ^1A   |    7   |     0.4914836  |      13.37395  |    107868.191  |  97.38  |
#  | ^1A   |    8   |     0.4914836  |      13.37395  |    107868.191  |  97.09  |
#  +=============================================================================+
# 
# 
CRIT1=`$GREP "Total MP2-R12/B energy:              * \-40\.3940351575" $log | wc -l`
TEST[1]=`expr   $CRIT1`
CTRL[1]=2
ERROR[1]="MP2-R12/B ENERGY NOT CORRECT"
CRIT2=`$GREP "Total CC2-R12/B energy:              * \-40\.3953862545" $log | wc -l`
TEST[2]=`expr   $CRIT2`
CTRL[2]=2
ERROR[2]="CC2-R12/A ENERGY NOT CORRECT"
#
CRIT3=`$GREP "[ \|]* \^1A[ \|]* 1[ \|]* ( |0)\.41760..[ \|]* 11\.3636.[ \|]* 91653\....[ \|]" $log | wc -l`
TEST[3]=`expr   $CRIT3`
CTRL[3]=1
ERROR[3]="CC2-R12/B 1A1 EXCITATION ENERGY NOT CORRECT"
CRIT4=`$GREP "[ \|]* \^1A[ \|]* 2[ \|]* ( |0)\.41760..[ \|]* 11\.3636.[ \|]* 91653\....[ \|]" $log | wc -l`
TEST[4]=`expr   $CRIT4`
CTRL[4]=1
ERROR[4]="CC2-R12/B 2A1 EXCITATION ENERGY NOT CORRECT"
CRIT5=`$GREP "[ \|]* \^1A[ \|]* 3[ \|]* ( |0)\.41760..[ \|]* 11\.3636.[ \|]* 91653\....[ \|]" $log | wc -l`
TEST[5]=`expr   $CRIT5`
CTRL[5]=1
ERROR[5]="CC2-R12/B 3A1 EXCITATION ENERGY NOT CORRECT"
CRIT6=`$GREP "[ \|]* \^1A[ \|]* 4[ \|]* ( |0)\.48277..[ \|]* 13\.1370.[ \|]* 105957\....[ \|]" $log | wc -l`
TEST[6]=`expr   $CRIT6`
CTRL[6]=1
ERROR[6]="CC2-R12/B 4A1 EXCITATION ENERGY NOT CORRECT"
CRIT7=`$GREP "[ \|]* \^1A[ \|]*  5[ \|]* ( |0)\.48277..[ \|]* 13\.1370.[ \|]* 105957\....[ \|]" $log | wc -l`
TEST[7]=`expr   $CRIT7`
CTRL[7]=1
ERROR[7]="CC2-R12/B 5A1 EXCITATION ENERGY NOT CORRECT"
CRIT8=`$GREP "[ \|]* \^1A[ \|]* 6[ \|]* ( |0)\.48277..[ \|]* 13\.1370.[ \|]* 105957\....[ \|]" $log | wc -l`
TEST[8]=`expr   $CRIT8`
CTRL[8]=1
ERROR[8]="CC2-R12/B 6A1 EXCITATION ENERGY NOT CORRECT"
CRIT9=`$GREP "[ \|]* \^1A[ \|]* 7[ \|]* ( |0)\.49148..[ \|]* 13\.3739.[ \|]* 107868\....[ \|]" $log | wc -l`
TEST[9]=`expr   $CRIT9`
CTRL[9]=1
ERROR[9]="CC2-R12/B 7A1 EXCITATION ENERGY NOT CORRECT"
CRIT10=`$GREP "[ \|]* \^1A[ \|]* 8[ \|]* ( |0)\.49148..[ \|]* 13\.3739.[ \|]* 107868\....[ \|]" $log | wc -l`
TEST[10]=`expr   $CRIT10`
CTRL[10]=1
ERROR[10]="CC2-R12/B 8A1 EXCITATION ENERGY NOT CORRECT"


PASSED=1
for i in 1 2 3 4 5 6 7 8 9 10 
do 
   if [ ${TEST[i]} -ne ${CTRL[i]} ]; then
     echo "${ERROR[i]} ( test = ${TEST[i]}; control = ${CTRL[i]} ); "
     PASSED=0
   fi
done 

if [ $PASSED -eq 1 ]
then
  echo TEST ENDED PROPERLY
  exit 0
else
  echo THERE IS A PROBLEM 
  exit 1
fi

%EOF%
#######################################################################
